package org.obm.lmtp.impl;

import java.io.IOException;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.obm.mina.MinaCodecFactory;
import org.obm.mina.MinaHandler;
import org.obm.mina.MinaServer;
import org.obm.mina.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MinaLmtpServer extends MinaServer<LmtpConfig> {

	private static final Logger logger = LoggerFactory
			.getLogger(MinaLmtpServer.class);

	public static boolean isEnabled() {
		return true;
	}

	public MinaLmtpServer(LmtpConfig config) throws IOException,
			ServiceException {
		super(config);
	}
	
	@Override
	public MinaHandler createHandler(IoSession session) {
		MinaLmtpHandler ret = new MinaLmtpHandler(this, session);
		return ret;
	}

	@Override
	protected ProtocolCodecFactory getProtocolCodecFactory() {
		return new MinaCodecFactory() {
			public ProtocolDecoder getDecoder(IoSession ios) {
				return new MinaLmtpDecoder();
			}
		};
	}

	@Override
	public Logger getLog() {
		return logger;
	}
}
